package com.mjk.common.base.error;



import com.mjk.common.base.response.BeeResponse;
import com.mjk.common.util.MDCUtils;


/**
 * 基础错误类
 * @author mjk
 *
 */

public interface IError {	
		
	BeeResponse tranceError(Object o);

    /**
	 * 转化错误
     * @param code 错误ID
     * @param msg 错误信息
     * @param o  具体信息
     * @return
	 */
	default BeeResponse tranceError(Integer code,String msg,Object o){
		BeeResponse response = new BeeResponse();		
		response.setCode(code);
		response.setMsg(msg);
		response.setStatus(code==1?0:code);
		response.setData(o);
		response.setTraceId(MDCUtils.getTraceId());
		return response;
	}
	
	default BeeResponse tranceError(Integer code,String msg,Integer logleavel,Object o){
		BeeResponse response = new BeeResponse();		
		response.setCode(code);
		response.setMsg(msg);
		response.setTraceId(MDCUtils.getTraceId());
		response.setLogLeavel(logleavel+"");
		response.setData(o);
		return response;
	}
}
